package com.psp.park.persist.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.psp.park.model.OrderBean;
import com.psp.park.model.ParkAdminOrderBean;
import com.psp.park.persist.dao.OrderDao;

@Repository
public class OrderImpl extends BaseImpl implements OrderDao {
	final String NAME_SPACE = NAME_SPACE_HEADER + ".OrderMapper";

	@Override
	public int insert(OrderBean bean) {
		return sqlSessionTemplate.insert(NAME_SPACE + ".insert", bean);
	}

	@Override
	public OrderBean selectById(String oid) {
		return sqlSessionTemplate.selectOne(NAME_SPACE + ".selectById", oid);
	}

	@Override
	public int selectCount(String adminId, String orderNo, int[] state) {
		Map<String, Object> where = new HashMap<>();
		where.put("aid", adminId);
		where.put("orderNo", orderNo);
		where.put("state", state);// 订单状态
		return sqlSessionTemplate.selectOne(NAME_SPACE + ".selectCount", where);
	}

	@Override
	public List<OrderBean> selectList(int page, int pageSize, String adminId, String orderNo, int[] state) {
		Map<String, Object> where = new HashMap<>();
		where.put("aid", adminId);
		where.put("orderNo", orderNo);
		where.put("state", state);// 订单状态
		where.put("start", page * pageSize);
		where.put("length", pageSize);
		return sqlSessionTemplate.selectList(NAME_SPACE + ".selectList", where);
	}

	@Override
	public int insertParkAdminOrder(ParkAdminOrderBean pOrder) {
		return sqlSessionTemplate.insert(NAME_SPACE + ".insertParkAdminOrder", pOrder);
	}

}
